import { createVNode, render } from "vue"
import XtxMessage from './XtxMessage.vue'

const divVNode = createVNode('div', { class: 'xtx-message-container' })
render(divVNode, document.body)
const div = divVNode.el
let timer = null
const Message = ({ type, message }) => {
    clearTimeout(timer)

    const messageVNode = createVNode(XtxMessage, { type, message })
    render(messageVNode, div)

    timer = setTimeout(() => {
        render(null, div)
    }, 3000);
}

export default Message